/*
 * @Author: yxfan
 * @Date: 2024-12-16 18:31:27
 * @LastEditTime: 2025-01-11 17:48:22
 * @FilePath: /umi-demo/src/pages/test/redux/index.jsx
 * @Description:
 */
import { lazy, Suspense } from 'react';
import { useSelector, useDispatch } from 'umi';
import Son from './Son';
import { useBearStore, useBearStoreShallow } from './store';
// import Foo from 'dumiApp/Foo';
// const Button = lazy(() => import('remote/Button'));
// import utils from 'dumiApp/utils';

export default () => {
    // const { num } = useSelector((state) => state.redux);
    // const bears = useBearStore((state) => state.bears);

    // console.log('Parent render', useBearStore.getState());
    // console.log(utils);
    const dispatch = useBearStoreShallow((state) => state.dispatch);
    function change() {
        dispatch({
            type: 'setParent',
            payload: 'Parent',
        });
    }

    return (
        <div>
            <h2>父组件</h2>
            <button onClick={change}>更改</button>
            <Son />
            <Suspense fallback={<div>Loading...</div>}>
                {/* <Button title="xxx" /> */}
            </Suspense>
        </div>
    );
};
